﻿using ClassLibrary;
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleDemo
{
    public class ActionDemo
    {
        public static void ActionDelegateDemo()
        {
            List<Person> personList = GetPersonList();

            personList.ForEach(new Action<Person>(delegate (Person p)
            {
                Console.WriteLine(p.ID + "-" + p.Name + "-" + p.Age);
            }));

            var ageList = personList.FindAll(p => p.Age > 30);

            var stuList = personList.Select(p => new Student() { StID = p.ID, LastName = p.Name });

            personList.Where(p => p.Age > 10);
        }

        public static List<Person> GetPersonList()
        {
            return new List<Person>()
            {
                new Person() { ID = 1, Name = "鹿晗", Age = 33},
                new Person() { ID = 2, Name = "侯明昊", Age = 26}
            };
        }
    }
}
